package com.longdaji.decoration.ui.activitiesOfMine.housemaster.wallet;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.longdaji.decoration.R;
import com.longdaji.decoration.adapter.ProfitAdapter;
import com.longdaji.decoration.base.BaseActivity;
import com.longdaji.decoration.bean.Profit;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WalletActivity extends BaseActivity implements WalletContract.IView {

    @Inject
    WalletContract.IPresenter mPresenter;
    @BindView(R.id.tv_tool_title)
    TextView tvTitle;
    @BindView(R.id.tv_total_profit)
    TextView tvTotalProfit;
    @BindView(R.id.rv_profit)
    RecyclerView rvProfit;

    private ProfitAdapter mAdapter;
    private List<Profit> mProfitList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet);
        setUnBinder(ButterKnife.bind(this));
        if (mPresenter != null)
            mPresenter.setView(this);
        tvTitle.setText("我的收益");

        initView();
    }

    private void initView() {
        rvProfit.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new ProfitAdapter(mProfitList);
        rvProfit.setAdapter(mAdapter);
        // TODO: 2018/4/7 0007 setData();
        initList();
//        mAdapter.setData(mProfitList);
    }

    private void initList() {
        // TODO: 2018/4/7 0007 这里应该是从网络获取，现在只是作为例子
        Profit profit = new Profit("17栋", 2, "1-2 12:00");
        mProfitList.add(profit);
        Profit profit2 = new Profit("17栋220宿舍", 1, "2-2 13:00");
        mProfitList.add(profit2);
        Profit profit3 = new Profit("15栋501宿舍", 6, "1-3 14:00");
        mProfitList.add(profit3);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null)
            mPresenter.detachView();
    }

    @OnClick({R.id.rl_tool_back})
    void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_tool_back:
                finish();
                break;
            default:
                break;
        }
    }
}
